
//2594.修理的最少时间
class Solution {
    long long check(vector<int>& ranks,long long t)
    {
        long long ret=0;  //统计修理好的车辆
        for(auto r:ranks) ret+=sqrt(t/r);  

        return ret;
    }

public:
    long long repairCars(vector<int>& ranks, int cars) {
        //确定上下边界
        long long left=0,right=0;
        long long r_min=ranges::min(ranks);
        right=r_min*cars*cars;
        
        while(left+1<right)
        {
            long long mid=left+(right-left)/2;
            if(check(ranks,mid)>=cars) right=mid;
            else left=mid;
        }
        return right;
    }
};